package mqpaydemo.paydemo.pay.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import mqpaydemo.paydemo.pay.api.OrdersService;
import mqpaydemo.paydemo.pay.orm.entity.Orders;

import mqpaydemo.paydemo.pay.orm.mapper.OrdersMapper;
import mqpaydemo.paydemo.pay.request.OrdersRequest;
import mqpaydemo.paydemo.pay.response.Result;
import mqpaydemo.paydemo.pay.util.Sequence;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ljs
 * @since 2021-09-10
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
    @Resource
    OrdersService OrdersService;
    @Override
    public Result<Boolean> pay(OrdersRequest OrdersRequest){
        Orders Orders=new Orders();
        Sequence sequence=new Sequence();
        Long id= sequence.nextId();
        Orders.setId(id);
        BeanUtils.copyProperties(OrdersRequest,Orders);
        Boolean bln= OrdersService.save(Orders);
        return  Result.ofSuccess(bln);
    }

}